package com.sojson.util;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

import com.sojson.config.task.bean.TdHandler;

/**
 * 线程参数工具类
 *
 * @author liu
 * @date 2024-09-24
 */
public class ThreadLocalUtil {

    public static List<TdHandler<?>> HANDLERS = new ArrayList<TdHandler<?>>();

    public static void addHandler(TdHandler<?> handler) {
        HANDLERS.add(handler);
        sortHandler();
    }

    private static void sortHandler() {
        HANDLERS.sort(new Comparator<TdHandler<?>>() {
            @Override
            public int compare(TdHandler<?> o1, TdHandler<?> o2) {
                return o1.getSort() - o2.getSort();
            }
        });
    }

}